﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EditPlatformTool
{
    public class LogControl
    {
        private static RichTextBox _Device = null;
        private static LogControl _pInstance;
        public enum LogType { Info, Warning, Error };
        private LogControl() { }
        public static LogControl GetInstance()
        {
            if (_pInstance == null)
                _pInstance = new LogControl();
            return _pInstance;
        }

        public void SetDevice(Object obj)
        {
            _Device = (RichTextBox)obj;
        }

        static public void PrintLog(LogType logType, string value)
        {
            String loginfo = "";

            switch(logType)
            {
                case LogType.Info:
                    loginfo = "Info: ";
                    break;
                case LogType.Warning:
                    loginfo = "Warning: ";
                    break;
                case LogType.Error:
                    loginfo = "Error: ";
                    break;
                default:
                    break;
            }

            _Device.AppendText(loginfo + value+"\n");
        }
    }
}
